package com.noble.glamour.ui.discover.task;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.noble.meether.R;
import com.noble.glamour.bean.center.user.detail.UserDetail;
import com.noble.glamour.module.logic.application.ModuleMgr;
import com.noble.library.view.base.BaseDialogFragment;
import com.noble.meether.MeetUIShow;

/**
 * 资料认证提示弹框
 */
public class UserAuthDialog extends BaseDialogFragment implements View.OnClickListener {

    public UserAuthDialog() {
        settWindowAnimations(R.style.AnimDownInDownOutOverShoot);
        setGravity(Gravity.BOTTOM);
        setDialogSizeRatio(-2, -2);
        setCancelable(false);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        setContentView(R.layout.f1_user_auth_dialog);
        initData();
        initView();
        return getContentView();
    }

    private void initData() {
    }

    private void initView() {
        Button user_auth_sure_btn = (Button) findViewById(R.id.user_auth_sure_btn);
        TextView user_auth_title = (TextView) findViewById(R.id.user_auth_title);
        user_auth_sure_btn.setOnClickListener(this);
        findViewById(R.id.user_auth_cancel_btn).setOnClickListener(this);

        UserDetail userDetail = ModuleMgr.getCenterMgr().getMyInfo();
        if (userDetail.getStatusAuth() == -3) {
            return;
        }
        if (userDetail.getStatusAuth() == -1) { // 未通过
            user_auth_title.setText("未通过，请重新认证！");
        } else if (userDetail.getStatusAuth() == -2) {
            user_auth_title.setText("审核中，请耐心等待！");
        }
        user_auth_sure_btn.setText("重新认证");
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.user_auth_sure_btn:
                MeetUIShow.showSexAuthAct((FragmentActivity) getContext());
                dismiss();
                break;
            case R.id.user_auth_cancel_btn:
                dismiss();
                break;
        }
    }
}
